NXT_SetInputMode
Sets mode, configures and initializes sensor ready to be read out
Contents
Syntax
status = NXT_SetInputMode(port, SensorTypeDesc, SensorModeDesc, ReplyMode)
status = NXT_SetInputMode(port, SensorTypeDesc, SensorModeDesc, ReplyMode, handle)
Description
status = NXT_SetInputMode(InputPort, SensorTypeDesc, SensorModeDesc, ReplyMode) sets mode, configures and initializes the given sensor port to be ready to be read out. The value port can be addressed by the symbolic constants SENSOR_1, SENSOR_2, SENSOR_3 and SENSOR_4 analog to the labeling on the NXT Brick. The value SensorTypeDesc determines the sensor type. See all valid types below. SensorModeDesc represents the sensor mode. It specifies what mode the .ScaledVal from NXT_GetInputValues should be. Valid parameters see below. By the ReplyMode one can request an acknowledgement for the packet transmission. The two strings 'reply' and 'dontreply' are valid. The return value status indicates if an error occures by the packet transmission.
status = NXT_SetInputMode(InputPort, SensorTypeDesc, SensorModeDesc, ReplyMode, handle) uses the given NXT connection handle. This should be a struct containing a serial handle on a PC system and a file handle on a Linux system.
If no NXT handle is specified the default one (COM_GetDefaultNXT) is used.
Input:
SensorTypeDesc: Valid types are (all strings):
NO_SENSOR (nothing, use to close sensor port)
SWITCH (NXT touch sensor, "binary")
LIGHT_ACTIVE (NXT light sensor, red LED is on)
LIGHT_INACTIVE (NXT light sensor, red LED is off)
SOUND_DB (NXT sound sensor, unit dB)
SOUND_DBA (NXT sound sensor, unit dBA)
LOWSPEED (NXT, passive digital sensor)
LOWSPEED_9V (NXT, active digital sensor, e.g. UltraSonic)
TEMPERATURE (old RCX sensor)
REFLECTION (old RCX sensor)
ANGLE (old RCX sensor)
CUSTOM (user defined)
SensorModeDesc: Valid modes are (all strings):
RAWMODE (Fastest. RawADVal will be used)
BOOLEANMODE (1 if above 45% threshold, else 0)
TRANSITIONCNTMODE (count transitions of booleanmode)
PERIODCOUNTERMODE (counr periods (up and down transition) of boolean mode)
PCTFULLSCALEMODE (normalized percentage between 0 and 100, use .NormalizedADVal instead!)
More exotic modes are: CELSIUSMODE (RCX temperature only)
FAHRENHEITMODE (RCX temperature only)
ANGLESTEPSMODE (RCX rotation only)
SLOPEMASK (what's this???)
MODEMASK (what's this???)
For more details see the official LEGO Mindstorms communication protocol.
Examples
status = NXT_SetInputMode(SENSOR_1, 'SOUND_DB', 'RAWMODE', 'dontreply');
handle = COM_OpenNXT('bluetooth.ini','check'); status = NXT_SetInputMode(SENSOR_3, 'LIGHT_ACTIVE', 'RAWMODE', 'dontreply', handle);
See also
NXT_GetInputValues, OpenLight, OpenSound, OpenSwitch, OpenUltrasonic, CloseSensor, SENSOR_1, SENSOR_2, SENSOR_3, SENSOR_4
Signature
- Author: Linus Atorf (see AUTHORS)
- Date: 2007/10/15
- Copyright: 2007-2008, RWTH Aachen University